/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package View.Administrator;

import Controllers.MovieController;
import Entities.Movie;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.swing.JList;

/**
 *
 * @author sebastian
 */
public class RemoveConfirmation extends javax.swing.JFrame {
 MovieController mC = new MovieController(); 
    JList jlist = new JList();
    /**
     * Creates new form RemoveConfirmation
     */
    public RemoveConfirmation() {
           initComponents();   
        
    }

   public void RemoveConfirmationName(String nametoremove, JList jlist) {
          
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("GRLU");
        this.labelMovieName.setText(nametoremove);
        this.jlist = jlist;
        //this.labelMovieName.setAlignmentX((this.getSize().width - nametoremove.length())/2);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        confirmRemoveMovie = new javax.swing.JButton();
        CancelRemove = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        labelMovieName = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();

        confirmRemoveMovie.setText("SURE!");
        confirmRemoveMovie.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                confirmRemoveMovieActionPerformed(evt);
            }
        });

        CancelRemove.setText("NO, i like this movie");
        CancelRemove.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CancelRemoveActionPerformed(evt);
            }
        });

        jLabel1.setText("Are u sure that you want the movie");

        jLabel2.setFont(new java.awt.Font("Ubuntu", 0, 48)); // NOI18N
        jLabel2.setText("?");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(labelMovieName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(122, 122, 122)
                        .addComponent(jLabel2)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(confirmRemoveMovie)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(CancelRemove)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addComponent(labelMovieName, javax.swing.GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(confirmRemoveMovie)
                    .addComponent(CancelRemove))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void CancelRemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CancelRemoveActionPerformed
        this.setVisible(false);
    }//GEN-LAST:event_CancelRemoveActionPerformed

    private void confirmRemoveMovieActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_confirmRemoveMovieActionPerformed
        Integer indexM = jlist.getSelectedIndex();
        String nametoremove = jlist.getSelectedValue().toString(); 
      //  System.out.println(nametoremove);            
        mC.removeSelectedMovie(nametoremove);
        this.setVisible(false);
         jlist.setListData(mC.getAllMoviesNames());
        jlist.setSelectedIndex(0);
        
     

    }//GEN-LAST:event_confirmRemoveMovieActionPerformed
    
    public Movie removedMovie(String movieRemoved){
        return null;
   
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(RemoveConfirmation.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(RemoveConfirmation.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(RemoveConfirmation.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(RemoveConfirmation.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new RemoveConfirmation().setVisible(true);
                
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton CancelRemove;
    private javax.swing.JButton confirmRemoveMovie;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel labelMovieName;
    // End of variables declaration//GEN-END:variables
}
